package org.jeecg.modules.materia.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.modules.materia.entity.CrdMaterialInfo;
import org.jeecg.modules.materia.entity.GroupInfoBo;
import org.jeecg.modules.materia.mapper.CrdMaterialInfoMapper;
import org.jeecg.modules.materia.service.ICrdMaterialInfoService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;
import java.util.Map;

/**
 * @Description: 素材信息
 * @Author: jeecg-boot
 * @Date:   2020-05-02
 * @Version: V1.0
 */
@Service
public class CrdMaterialInfoServiceImpl extends ServiceImpl<CrdMaterialInfoMapper, CrdMaterialInfo> implements ICrdMaterialInfoService {

    @Override
    public List<GroupInfoBo> queryGroupInfo(Integer materialType) {
        //全部
        QueryWrapper<CrdMaterialInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("del_flag",0);
        queryWrapper.eq("material_type",materialType);
        int allCnt = this.count(queryWrapper);
        //未分类
        queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("del_flag",0);
        queryWrapper.eq("material_type",materialType);
        queryWrapper.eq("group_id","0");
        int noGroupCnt = this.count(queryWrapper);

        List<GroupInfoBo> list = this.baseMapper.queryGroupInfo(materialType);
        list.add(0,new GroupInfoBo("全部","",allCnt));
        list.add(1,new GroupInfoBo("未分组","0",noGroupCnt));

        return list;
    }
}
